package com.ruoyi.web.controller.front;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.framework.web.service.SysLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户登录
 *
 * @author ty
 */
@RestController
@Anonymous
@RequestMapping("/front")
public class UserLoginController {
    @Autowired
    private SysLoginService loginService;


    /**
     * 用户登录
     *
     * @param LoginBody 登录信息
     * @return 结果
     */

    @PostMapping("/login")
    public AjaxResult login(LoginBody LoginBody) {
        AjaxResult ajax = AjaxResult.success();
        // 生成令牌
        String token = loginService.login(LoginBody.getUsername(), LoginBody.getPassword(), LoginBody.getCode(), LoginBody.getUuid());
        ajax.put("token", token);
        return ajax;
    }
}

